<template>
	<view>
		主页
		<view class="test" @click="testClick">testClick</view>
		<button open-type="getUserInfo" @getuserinfo="getUserInfo">获取用户信息</button>
		<button open-type="getPhoneNumber" @getPhoneNumber="getPhoneNumber">获取用户手机号码(需要企业认证开发者)</button>
	</view>
</template>

<script>

	export default {
		data() {
			return {
				
			};
		},
		onShow() {
			
		},
		methods: {
			testClick: async function() {
				uni.showToast({
					title: 'testClick'
				});
				const code = await this.$utils.wxLogin();
				console.log(code);
				const a = 1;
				uni.navigateTo({
					url: '/pagesA/login/login',
					events: {
						// 为指定事件添加一个监听器，获取被打开页面传送到当前页面的数据
						acceptDataFromLoginPage: function(data) {
							console.log('acceptDataFromLoginPage', data)
						},
					},
					success: function(res) {
						// 通过eventChannel向被打开页面传送数据
						res.eventChannel.emit('acceptDataFromHomePage', { data: 'test' })
					},
					fail: res => {
						console.log('fail', res)
					},
				});
			},
			getUserInfo: res => {
				console.log('getUserInfo', res);
			},
			getPhoneNumber: res => {
				console.log('getPhoneNumber', res);
			},
		}
	}
</script>

<style scoped lang="less">
	.test {
		text-align: center;
		font-size: 18px;
		color: red;
	}
</style>
